********************************************************************
* FILE: HansfordGomez_APSR_2010.do                                 *
* AUTHORS: Tom Hansford, UC Merced, and Brad Gomez, FSU            *
*                                                                  *
* This file provides the Stata code necessary to replicate all of  *
* the statistical results presented in Hansford and Gomez. 2010.   *
* "Estimating the Electoral Effects of Voter Turnout." AMERICAN    *
* POLITICAL SCIENCE REVIEW 104 (May): 268-288.                     *
*                                                                  *
* NOTE: The published results were obtained using STATA 9.  There  *
* appears to have been a change in how STATA 11 estimates robust   *
* standard errors with panel models--only clustered standard       *
* errors are now estimated while in the past non-clustered robust  *
* standard errors were estimated unless otherwise specified.  This *
* does not affect any of the xtivreg2 models, but it does slightly *
* change the standard errors of the xtreg models.  Setting STATA   *
* to "version 9"--using the version command--does not correct this *
* issue.                                                           *
*                                                                  *
* Also, users should note that because we do not set a random-     *
* number seed for the bootstrap standard errors, the reported SEs  *
* and Wald chi2--due to resampling--will vary across estimations.  *
* Thus, while you will obtain the same point estimates found in    *
* our APSR article by using this code, you are unlikely to match   *
* our exact standard errors and Wald chi2.                         *
*                                                                  *
* Before running this .do file you will need to download three     *
* STATA modules:                                                   *
*                                                                  *
* The DMEXOGXT module tests the consistency of OLS v. XT-IV        *
* estimates.  The file can be obtained here:                       *
*                                                                  *
*        http://ideas.repec.org/c/boc/bocode/s401103.html          *
*                                                                  *
* The IVREG2 module for extended instrumental variables/2SLS and   *
* GMM estimation.  The file can be obtained here:                  *
*                                                                  *
*        http://ideas.repec.org/c/boc/bocode/s425401.html          *
*                                                                  *
* The XTIVREG2 module performs IV/2SLS, GMM and AC/HAC, LIML and   *
* k-class regression for panel data models.  The file can be       *
* obtained here:                                                   *
*                                                                  *
*        http://ideas.repec.org/c/boc/bocode/s456501.html          *
*                                                                  *
* Please cite our article when using our data, and send any        *
* questions or comments to Tom Hansford (thansford@ucmerced.edu)   *
* or Brad Gomez (bgomez@fsu.edu).                                  *
********************************************************************

set more off

*** BRING IN THE DATA (SPECIFY YOUR DIRECTORY) ***

use "C:\Your Directory\HansfordGomez_Data.dta"

xtset FIPS_County Year

*** TESTING FOR ENDOGENEITY, p. 276 ***

quietly: xtivreg DemVoteShare2 DemVoteShare2_3MA Yr52 Yr56 Yr60 Yr64 Yr68 /*
*/ Yr72 Yr76 Yr80 Yr84 Yr88 Yr96 Yr92 Yr2000 (Turnout GOPIT TO_DVS23MA =  /*
*/ DNormPrcp_KRIG RainGOPI Rain_DVS23MA), fe

dmexogxt


*** TABLE 1 - COLUMN 1 ***

xtreg DemVoteShare2 DemVoteShare2_3MA Yr52 Yr56 Yr60 Yr64 Yr68 Yr72 Yr76 /*
*/ Yr80 Yr84 Yr88 Yr96 Yr92 Yr2000 Turnout GOPIT TO_DVS23MA, fe robust


*** TABLE 1 - COLUMN 2 ***
	
xtivreg2 DemVoteShare2 DemVoteShare2_3MA Yr52 Yr56 Yr60 Yr64 Yr68 Yr72 /*
*/ Yr76 Yr80 Yr84 Yr88 Yr96 Yr92 Yr2000 (Turnout GOPIT TO_DVS23MA =    /*
*/ DNormPrcp_KRIG RainGOPI  Rain_DVS23MA), fe robust


*** TABLE 1 - COLUMN 3 ***

xtivreg2 DemVoteShare2 DemVoteShare2_3MA Yr52 Yr56 Yr60 Yr64 Yr68 Yr72 /*
*/ Yr76 Yr80  Yr84 Yr88 Yr96 Yr92 Yr2000  State_DVS_lag State_DVS_lag2 /*
*/ Closing2  Literacy PollTax Motor GubElection SenElection  dph dvph  /*
*/ rph rvph  dph_StateVAP dvph_StateVAP rph_StateVAP rvph_StateVAP     /*
*/ state_del (Turnout GOPIT TO_DVS23MA = DNormPrcp_KRIG RainGOPI       /*
*/ Rain_DVS23MA), fe robust


*** TABLE 1 - COLUMN 2 - F-TESTS FOR EXCLUDED INSTRUMENTS ***

quietly: xtreg Turnout DemVoteShare2_3MA Yr52 Yr56 Yr60 Yr64 Yr68 Yr72 /*
*/ Yr76 Yr80 Yr84 Yr88 Yr96 Yr92 Yr2000 DNormPrcp_KRIG RainGOPI        /*
*/ Rain_DVS23MA, fe robust

test DNormPrcp_KRIG RainGOPI Rain_DVS23MA

quietly: xtreg TO_DVS23MA DemVoteShare2_3MA Yr52 Yr56 Yr60 Yr64 Yr68   /*
*/ Yr72 Yr76 Yr80 Yr84 Yr88 Yr96 Yr92 Yr2000 DNormPrcp_KRIG RainGOPI   /*
*/ Rain_DVS23MA, fe robust

test DNormPrcp_KRIG RainGOPI Rain_DVS23MA

quietly: xtreg GOPIT DemVoteShare2_3MA Yr52 Yr56 Yr60 Yr64 Yr68 Yr72   /*
*/ Yr76 Yr80 Yr84 Yr88 Yr96 Yr92 Yr2000 DNormPrcp_KRIG RainGOPI        /*
*/ Rain_DVS23MA, fe robust

test DNormPrcp_KRIG RainGOPI Rain_DVS23MA


*** TABLE 1 - COLUMN 3 - F-TESTS FOR EXCLUDED INSTRUMENTS ***

quietly: xtreg Turnout DemVoteShare2_3MA Yr52 Yr56 Yr60 Yr64 Yr68 Yr72 /*
*/ Yr76 Yr80 Yr84 Yr88 Yr96 Yr92 Yr2000 State_DVS_lag State_DVS_lag2   /*
*/ Closing2 Literacy PollTax Motor GubElection SenElection dph dvph    /*
*/ rph rvph dph_StateVAP dvph_StateVAP rph_StateVAP rvph_StateVAP      /*
*/ state_del DNormPrcp_KRIG RainGOPI Rain_DVS23MA, fe robust

test DNormPrcp_KRIG RainGOPI Rain_DVS23MA

quietly: xtreg TO_DVS23MA DemVoteShare2_3MA Yr52 Yr56 Yr60 Yr64 Yr68   /*
*/ Yr72 Yr76 Yr80 Yr84 Yr88 Yr96 Yr92 Yr2000 State_DVS_lag             /*
*/ State_DVS_lag2 Closing2 Literacy PollTax Motor GubElection          /*
*/ SenElection dph dvph rph rvph dph_StateVAP dvph_StateVAP            /*
*/ rph_StateVAP rvph_StateVAP state_del DNormPrcp_KRIG RainGOPI        /*
*/ Rain_DVS23MA, fe robust

test DNormPrcp_KRIG RainGOPI Rain_DVS23MA

quietly: xtreg GOPIT DemVoteShare2_3MA Yr52 Yr56 Yr60 Yr64 Yr68 Yr72   /*
*/ Yr76 Yr80 Yr84 Yr88 Yr96 Yr92 Yr2000 State_DVS_lag State_DVS_lag2   /*
*/ Closing2 Literacy PollTax Motor GubElection SenElection dph dvph    /*
*/ rph rvph dph_StateVAP dvph_StateVAP rph_StateVAP rvph_StateVAP      /*
*/ state_del DNormPrcp_KRIG RainGOPI Rain_DVS23MA, fe robust

test DNormPrcp_KRIG RainGOPI Rain_DVS23MA


*** TABLE 3 - COLUMN 1 ***

quietly: xtreg DemVoteShare2 DemVoteShare2_3MA Yr52 Yr56 Yr60 Yr64     /*
*/ Yr68 Yr72 Yr76 Yr80 Yr84 Yr88 Yr96 Yr92 Yr2000 Turnout GOPIT        /*
*/ TO_DVS23MA, fe robust

predict resid_ols, e

gen resid_ols2 = resid_ols^2

xtreg resid_ols2 Turnout Yr52 Yr56 Yr60 Yr64 Yr68 Yr72 Yr76 Yr80 Yr84  /*
*/ Yr88 Yr92 Yr96 Yr2000, fe vce(bootstrap, rep(500))


*** TABLE 3 - COLUMN 2 ***

quietly: xtivreg2 DemVoteShare2 DemVoteShare2_3MA Yr52 Yr56 Yr60 Yr64  /*
*/ Yr68 Yr72 Yr76 Yr80 Yr84 Yr88 Yr96 Yr92 Yr2000 (Turnout GOPIT       /*
*/ TO_DVS23MA = DNormPrcp_KRIG  RainGOPI  Rain_DVS23MA), fe robust

predict resid_iv, e

gen resid_iv2 = resid_iv^2

quietly: xtreg Turnout DemVoteShare2_3MA Yr52 Yr56 Yr60 Yr64 Yr68 Yr72 /*
*/ Yr76 Yr80 Yr84 Yr88 Yr96 Yr92 Yr2000 DNormPrcp_KRIG RainGOPI        /*
*/ Rain_DVS23MA, fe robust

predict pred_to, xb

xtreg resid_iv2 pred_to Yr52 Yr56 Yr60 Yr64 Yr68 Yr72 Yr76 Yr80 Yr84   /*
*/ Yr88 Yr92 Yr96 Yr2000, fe vce(bootstrap, rep(500))

drop pred_to


*** TABLE A1 - COLUMN 1 ***

xtreg Turnout DemVoteShare2_3MA Yr52 Yr56 Yr60 Yr64 Yr68 Yr72 Yr76     /*
*/ Yr80 Yr84 Yr88 Yr96 Yr92 Yr2000 DNormPrcp_KRIG RainGOPI             /*
*/ Rain_DVS23MA, fe robust

test DNormPrcp_KRIG RainGOPI Rain_DVS23MA


*** TABLE A1 - COLUMN 2 ***

xtreg TO_DVS23MA DemVoteShare2_3MA Yr52 Yr56 Yr60 Yr64 Yr68 Yr72 Yr76  /*
*/ Yr80 Yr84 Yr88 Yr96 Yr92 Yr2000 DNormPrcp_KRIG RainGOPI             /*
*/ Rain_DVS23MA, fe robust

test DNormPrcp_KRIG RainGOPI Rain_DVS23MA


*** TABLE A1 - COLUMN 3 ***

xtreg GOPIT DemVoteShare2_3MA Yr52 Yr56 Yr60 Yr64 Yr68 Yr72 Yr76 Yr80  /*
*/ Yr84 Yr88 Yr96 Yr92 Yr2000 DNormPrcp_KRIG RainGOPI Rain_DVS23MA, fe /*
*/ robust

test DNormPrcp_KRIG RainGOPI Rain_DVS23MA


*** TABLE A1 - COLUMN 4 ***

xtreg Turnout DemVoteShare2_3MA Yr52 Yr56 Yr60 Yr64 Yr68 Yr72 Yr76 Yr80 /*
*/ Yr84 Yr88 Yr96 Yr92 Yr2000 DNormPrcp_KRIG, fe robust

test DNormPrcp_KRIG


*** TABLE A2 ***

quietly: xtreg Turnout DemVoteShare2_3MA Yr52 Yr56 Yr60 Yr64 Yr68 Yr72 /*
*/ Yr76 Yr80 Yr84 Yr88 Yr96 Yr92 Yr2000 DNormPrcp_KRIG, fe robust

predict pred_to, xbu

gen PT_GOPI=pred_to*GOP_Inc

gen PT_DVS23MA= pred_to*DemVoteShare2_3MA

xtreg DemVoteShare2 DemVoteShare2_3MA Yr52 Yr56 Yr60 Yr64 Yr68 Yr72    /*
*/ Yr76 Yr80 Yr84 Yr88 Yr96 Yr92 Yr2000 pred_to PT_GOPI PT_DVS23MA, fe /*
*/ vce(boot, rep(500))


*** TABLE A3 ***

quietly: xtreg DemVoteShare2 DemVoteShare2_3MA Yr52 Yr56 Yr60 Yr64     /*
*/ Yr68 Yr72 Yr76 Yr80 Yr84 Yr88 Yr96 Yr92 Yr2000 pred_to PT_GOPI      /*
*/ PT_DVS23MA, fe

predict resid_alt, e

gen resid_alt2=resid_alt^2

xtreg resid_alt2 pred_to Yr52 Yr56 Yr60 Yr64 Yr68 Yr72 Yr76 Yr80 Yr84  /*
*/ Yr88 Yr92 Yr96 Yr2000, fe vce(boot, rep(500))


*** END OF FILE ***
